﻿using System.Data.SqlTypes;
using HashFoo.SqlServer;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace HashFoo.SqlServerTests
{
    [TestClass]
    public class SqlTypeUtilTests
    {
        [TestMethod]
        public void string_can_be_converted_to_sqlchars()
        {
            const string stringToConvert = "convertMe";
            var expectedSqlChars = new SqlChars(stringToConvert.ToCharArray());

            var converted = stringToConvert.ToSqlChars();

            Assert.AreEqual(expectedSqlChars.ToSqlString().Value, converted.ToSqlString().Value);
        }

        [TestMethod]
        public void string_can_be_converted_to_sqlstring()
        {
            const string stringToConvert = "convertMe";
            var expectedSqlChars = new SqlString(stringToConvert);

            var converted = stringToConvert.ToSqlString();

            Assert.AreEqual(expectedSqlChars.Value, converted.Value);
        }

        [TestMethod]
        public void xml_string_can_be_converted_to_sqlxml()
        {
            const string xmlString = "<a><b>c</b></a>";

            var actualSqlXml = xmlString.ToSqlXml();

            Assert.AreEqual(xmlString, actualSqlXml.Value);
        }
    }
}
